//
//  XJGoodsDetailHeader.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/11.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJGoodsDetailHeader.h"

#import <SDCycleScrollView.h>
#import "UIImage+ColorImage.h"
#import "UILabel+CountDown.h"

@interface XJGoodsDetailHeader ()<SDCycleScrollViewDelegate>

/* 轮播图 */
@property (strong , nonatomic)SDCycleScrollView *cycleScrollView;
@property (nonatomic, strong) UILabel * countDownLab;//倒计时

@end

@implementation XJGoodsDetailHeader


#pragma mark - Intial
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpUI];
    }
    return self;
}

- (UILabel *)countDownLab{
    if (!_countDownLab) {
        UILabel * countDownLab = [UILabel new];
        self.countDownLab = countDownLab;
    }
    return _countDownLab;
}

- (void)setUpUI{
    self.backgroundColor = WHITE_COLOR;
    _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, KWidth, ADAPTHeight(375)) delegate:self placeholderImage:[UIImage imageWithColor:XJCOLOR_RGB(221, 221, 221)]];
    _cycleScrollView.autoScroll = NO; // 不自动滚动
    
    NSString * countDownTitle = @"  03:22:52后结束";
    [self.countDownLab setupCountDownTitle:countDownTitle height:40];
    [_cycleScrollView addSubview:self.countDownLab];
    self.countDownLab.sd_layout
    .centerXEqualToView(_cycleScrollView)
    .bottomSpaceToView(_cycleScrollView, 25)
    .widthIs(ADAPTWidth(220))
    .heightIs(40);

    [self addSubview:_cycleScrollView];
}

#pragma mark - 点击图片Bannar跳转
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    XJLog(@"点击了%zd轮播图",index);
}

#pragma mark - Setter Getter Methods
- (void)setShufflingArray:(NSArray *)shufflingArray{
    _shufflingArray = shufflingArray;
    _cycleScrollView.imageURLStringsGroup = shufflingArray;
}

@end
